package adapter;


import unit.Unit;
import be.kuleuven.cs.swop.api.ILocation;
import be.kuleuven.cs.swop.api.UnitState;

public class AUnit implements be.kuleuven.cs.swop.api.IUnit {
	
	private Unit unit;
	
	public AUnit(Unit unit){
		this.unit=unit;
	}

	@Override
	public ILocation getHomeLocation() {
		return new ALocation(unit.getHomeLocation().getLocation());
	}

	@Override
	public ILocation getLocation() {
		return new ALocation(unit.getCurrentLocation());
	}

	@Override
	public String getName() {
		return unit.getName();
	}

	@Override
	public UnitState getState() {
		if(unit.getToHospital()!=null)
			return UnitState.OCCUPIED;
		if(unit.isBroken())
			return UnitState.BROKEN;
		if(unit.isAssigned())
			return UnitState.ASSIGNED;
		if(unit.canBeAssigned())
			return UnitState.IDLE;
		else
			return UnitState.ANY;
	}
	
	public Unit getUnit(){
		return unit;
	}

}
